package com.hcy.performancepro.service.performanceTool.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fuled.test.tool_config.DisableUtil;
import com.hcy.performancepro.bo.performanceTool.RecordControllerBo;
import com.hcy.performancepro.dao.performanceTool.PerformanceToolControllerDao;
import com.hcy.performancepro.po.performanceTool.RecordController;
import com.hcy.performancepro.service.performanceTool.PerformanceToolControllerService;
import org.springframework.stereotype.Service;
import java.util.List;

@Service("performanceToolControllerServiceImpl")
@DisableUtil
public class PerformanceToolControllerServiceImpl extends ServiceImpl<PerformanceToolControllerDao, RecordController> implements PerformanceToolControllerService {

    public Wrapper<RecordController> getWrapper(RecordControllerBo recordControllerBo){
        LambdaQueryWrapper<RecordController> wrapper = Wrappers.lambdaQuery();
        wrapper.like(StrUtil.isNotBlank(recordControllerBo.getRequestId()), RecordController::getRequestId, recordControllerBo.getRequestId());
        wrapper.like(StrUtil.isNotBlank(recordControllerBo.getRequestMethod()), RecordController::getRequestMethod, recordControllerBo.getRequestMethod());
        wrapper.like(StrUtil.isNotBlank(recordControllerBo.getFunctionName()), RecordController::getFunctionName, recordControllerBo.getFunctionName());
        wrapper.like(StrUtil.isNotBlank(recordControllerBo.getModuleName()), RecordController::getModuleName, recordControllerBo.getModuleName());
        wrapper.like(StrUtil.isNotBlank(recordControllerBo.getTimestamp()), RecordController::getTimestamp, recordControllerBo.getTimestamp());
        wrapper.like(StrUtil.isNotBlank(recordControllerBo.getParams()), RecordController::getParams, recordControllerBo.getParams());
        wrapper.like(StrUtil.isNotBlank(recordControllerBo.getReturnMessage()), RecordController::getReturnMessage, recordControllerBo.getReturnMessage());
        wrapper.like(StrUtil.isNotBlank(recordControllerBo.getExceptionMessage()), RecordController::getExceptionMessage, recordControllerBo.getExceptionMessage());
        return wrapper;
    }

    @Override
    public List<RecordController> sarchlist(Integer currentPage, Integer pageSize, RecordControllerBo recordControllerBo) {
        return baseMapper.selectList(new Page<>(currentPage, pageSize), getWrapper(recordControllerBo));
    }

    @Override
    public Long countNumber(RecordControllerBo recordControllerBo) {
        return baseMapper.selectCount(getWrapper(recordControllerBo));
    }
}
